/*
  学习目标：组件性能优化-使用PureComponent
*/
import React from 'react';

export default class App extends React.Component {
  state = {
    count: 0,
    msg: '',
  };

  handleClick = () => {
    this.setState({ count: this.state.count + 1 });
  };

  handleClickMsg = () => {
    this.setState({ msg: this.state.msg + '~' });
  };

  render() {
    return (
      <div>
        <h1>数量： {this.state.count}</h1>
        <button onClick={this.handleClick}>点我修改数量</button>
        <button onClick={this.handleClickMsg}>点击修改msg</button>
        <Footer count={this.state.count}></Footer>
      </div>
    );
  }
}

// 使用React.PureComponent进行性能优化
class Footer extends React.PureComponent {
  render() {
    console.log('this.props.count  ----->  ', this.props.count);
    // console.log('render执行了Footer  ----->  ');
    return <div>我是Footer - {this.props.count}</div>;
  }
}
